<?php

namespace EM\NewsBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class CommentsController extends Controller
{
	public function showAction(){
	
		$repository=$this->getDoctrine()->getRepository('EMNewsBundle:Comments');
		$comments = $repository->findAll();	
		
		return $this->render('EMNewsBundle:Comment:list.html.twig',array('comments' => $comments));
	
	}
	public function editAction($id,$status)
    {
		
		$em = $this->getDoctrine()->getEntityManager();
		$comment=$em->getRepository('EMNewsBundle:Comments')->find($id);
		$comment->setStatus($status);
		//$form = $this->createForm(new CategoryType(), $comment);
		//$request = $this->getRequest();
		//-- En caso de que el request haya sido invocado por POST
		//   procesaremos el formulario
		//if($request->getMethod() == 'POST')
		//{
		//	$status=$this->get('request')->request->get('status');
			//if($form->isValid())
			//{
				
			$em->persist($comment);
			$em->flush();
			return $this->redirect($this->generateUrl('em_comments'));
			//}
		//}
		
    }
	
	
	
}
